<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <style>
      .arrow {
        width: 0px;
        height: 0px;
        border: 5px solid transparent;
        border-top: 5px solid black;
      }
      * {
        margin: 0;
        padding: 0;
      }
      .el-tooltip__popper {
        position: absolute;
        border-radius: 4px;
        padding: 10px;
        border: 1px solid #ccc;
        font-size: 12px;
        color: #fff;
        word-wrap: break-word;
        background-color: #303133;
      }
      .popper__arrow,
      .popper__arrow::after {
        position: absolute;
        width: 0;
        height: 0;
        border: 6px solid transparent;
      }
      .popper__arrow {
        bottom: -6px;
        border-top-color: #303133;
        border-bottom-width: 0;
      }
      .el-tooltip__popper {
        margin-bottom: 12px;
      }
      .box {
        width: 100px;
        height: 100px;
        line-height: 100px;
        text-align: center;
        border: 1px solid #ccc;
        margin: 200px auto;
      }
    </style>
    <script src="./popper.js"></script>
    <!-- 第一种实现方式 -->
    <div class="arrow"></div>
    <!-- elementui源码的实现方式 -->
    <div class="box"></div>
    <div class="el-tooltip__popper">
      <p>Hello PopperJS</p>
      <div class="popper__arrow"></div>
    </div>
    <script>
      var box = document.querySelector(".box"),
        popper = document.querySelector(".el-tooltip__popper"),
        pIntance = new Popper(box, popper, {
          placement: "top",
        });
    </script>
  </body>
</html>
